import { appFetch } from "@/utils/tools";

export const getWebsitesPageApi = (body: any) => appFetch(
  '/api/users/getUsersPage',
  {
    method: 'post',
    body: JSON.stringify(body)
  }
)

export const loginApi = (
  loginInfo: {
    username: string,
    password: string
  }
) => appFetch(
  '/api/login',
  {
    method: 'post',
    body: JSON.stringify(loginInfo)
  }
)

export const getCurrentUserInfoApi = () => appFetch(
  '/api/getCurrentUserInfo',
  {
    method: 'get',
  }
)

export const addUserApi = (body: any) => appFetch(
  '/api/users/addOne',
  {
    method: 'post',
    body: JSON.stringify(body)
  }
)

export const updateUserAppConfigApi = (
  _id: string,
  body: any
) => appFetch(
  `/api/users/updateUser/${_id}`,
  {
    method: 'put',
    body: JSON.stringify(body)
  }
)

export const deleteUsersApi = (ids: string[]) => appFetch(
  `/api/users/delete`,
  {
    method: 'delete',
    body: JSON.stringify({
      ids
    })
  }
)